/**
 * ${tableComment} Reducer
 *
 * @author motorfu
 * @email ffu@maxleap.com
 * @since ${date}
 */
import * as ${className}Type from '../actions/${className}Action';

const initialState = {
  modifyLoading: false,
  createLoading: false,
  batchRemoveLoading: false,
  pageLoading: false,
  pageData: {
    params: {},
    data: {}
  }
};

export default function ${module}(state = initialState, action) {
  switch (action.type) {
    case ${className}Type.${tableName?upper_case}_CREATE_LOADING: {
      state.createLoading = action.data;
      if (action.data){
        state.pageData.data={};
      }
      return Object.assign({}, state);
    }

    case ${className}Type.${tableName?upper_case}_MODIFY_LOADING: {
      state.modifyLoading = action.data;
      if (action.data){
        state.pageData.data={};
      }
      return Object.assign({}, state);
    }

    case ${className}Type.${tableName?upper_case}_BATCH_REMOVE_LOADING: {
      state.batchRemoveLoading = action.data;
      if (action.data){
        state.pageData.data={};
      }
      return Object.assign({}, state);
    }

    case ${className}Type.${tableName?upper_case}_PAGE_LOADING: {
      state.pageLoading = action.data;
      return Object.assign({}, state);
    }

    case ${className}Type.${tableName?upper_case}_PAGE_DATA: {
      state.pageLoading = false;
      state.pageData = action.data;
      return Object.assign({}, state);
    }
    default:
      return state;
  }
}